package com.btb.adapter.vo.request;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.btb.adapter.model.UpChainFish;
import com.btb.adapter.model.UpChainFishPart;
import com.google.common.collect.Lists;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Data
@ToString
public class Fish {
	private Integer id;
	private String sn;
	private Integer season;  // 后加字段
	private Integer race;
	private Long productionDate;
	private String cardTips;
	private String cardImage;
	private Integer type;
	private Long transactionNum;
	private Map<String, FishPart> part;

	public UpChainFish buildFish(final String owner, final String requestId) {
		return UpChainFish.builder()
				.owner(owner)
				.requestId(requestId)
				.clientId(id)
				.season(String.valueOf(season))
				.sn(sn)
				.race(race)
				.productionDate(productionDate)
				.cardTips(cardTips)
				.cardImage(cardImage)
				.type(type)
				.status("0")
				.build();
	}
	public List<UpChainFishPart> buildFishPart() {
		ArrayList<UpChainFishPart> list = Lists.newArrayList();
		part.forEach((k,v)->{
			UpChainFishPart build = UpChainFishPart.builder()
					.upChainFishClientId(id)
					.type(k)
					.no(v.getNo())
					.imgurl(v.getImgUrl())
					.addition(v.getAddition())
					.build();
			list.add(build);
		});
		return list;
	}
}
